home *** CD-ROM | disk | FTP | other *** search
- /*****
- CTRACE: A MESSAGE LOGGING CLASS
- by William D. Cramer in Dr. Dobbs Journal #170, p. 44-55, 116-120.
- *****/
-
- /** CTrace.h -- Definitions for using the Trace class **/
-
- #define _H_CTrace
-
- /* System/library header files */
- #include <Commands.h> /* standard menu command definition */
- #include <oops.h> /* standard OOP definitions */
- #include <stdarg.h> /* varg macro definitions */
- #include <CDesktop.h> /* definitions for desktop class */
- #include <CBartender.h> /* definitions for menu bar manager */
- #include <CDataFile.h> /* definitions for data file class */
- #include <CApplication.h> /* definitions for the application class */
- #include <CDocument.h> /* definitions for parent class */
- #include <Constants.h> /* miscellaneous environment constants */
-
- /* Local header files */
- #include "CLogPanorama.h" /* definitions for logging panorama class */
-
- /* Resource numbers */
- #define TRACE_MENU_ID (2000) /* menu resource ID */
- #define TRACE_MENU_SHOW (2000L) /* menu command for show/hide log */
- #define TRACE_MENU_MASK (2001L) /* menu command for log masking */
- #define TRACE_WINDOW_ID (2000) /* main window resource ID */
- #define TRACE_MASK_DIALOG (2000) /* resource ID for dialog box */
- #define FIRST_MASK (3) /* item # of first checkbox in dialog */
- #define LAST_MASK (34) /* item # of last checkbox in dialog */
- #define UNHILITE_CONTROL (255) /* magic part # for disabling control */
- #define OKAY_BUTTON_ITEM (1) /* item # for the 'okay' button */
- #define CANCEL_BUTTON_ITEM (2) /* item # for the 'cancel' button */
-
- /* Standard trace categories */
- #define T_ERROR (0x00000001) /* serious error */
- #define T_WARNING (0x00000002) /* mildly serious problem */
- #define T_INFO (0x00000004) /* news you can use */
- #define T_FUNC_IN (0x00000008) /* function entry */
- #define T_FUNC_OUT (0x00000010) /* function exit */
-
- /* Other constants */
- #define MAX_USER_BUFF (MAX_LOGREC_CHAR-19+1) /* max length of user message */
- #define TRACE_DEFAULT_MASK (0L) /* initial trace mask */
-
- /* External references */
- extern CDesktop *gDesktop; /* the whole desktop view */
- extern CApplication *gApplication; /* the application object */
- extern CBartender *gBartender; /* the menu bar object */
- extern OSType gSignature; /* application signature */
-
- struct CTrace : CDocument
- {
- /* local instance variables */
- CLogPanorama *itsLogPanorama; /* panorama for trace messages */
- unsigned long currMask; /* currently enabled trace categories */
- /* local class methods */
- void ITrace(short records);
- void ToggleTraceWindow(void);
- void SetTraceMask (void);
- void Trace (unsigned long mask, char *format, ...);
- Boolean IsItVisible(void);
- /* inherited methods overriden */
- void UpdateMenus (void);
- Boolean DoSaveAs (SFReply *macSFReply);
- Boolean Close (Boolean quitting);
- };
-